package com.lwk.utils;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
public class LwkUtil {

    public static void main(String[] args) {
        getCurrTime();
    }

    public static String getCurrTime() {
        LocalDateTime nowDateTime = LocalDateTime.now();
        //System.out.println(nowDateTime);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //System.out.println(dateTimeFormatter.format(nowDateTime));
        // 反着使用也可以
        //System.out.println(nowDateTime.format(dateTimeFormatter));
        return dateTimeFormatter.format(nowDateTime);
    }
}
